package net.siufung.market.base.user.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import net.siufung.core.model.EnumsVo;
import net.siufung.core.model.IEnum;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 陈建峰
 * @since 2022/7/6 5:23 下午
 */
@ToString
@AllArgsConstructor
public enum UserSupers implements IEnum<Boolean> {

    /**
     * 用户
     */
    NOT(false, "用户"),

    /**
     * 管理员
     */
    IS(true, "管理员");

    @Getter
    @Setter
    private Boolean value;

    @Getter
    @Setter
    private String desc;

    public static UserSupers get(Boolean value) {
        return IEnum.get(UserSupers.class,
                enums -> enums.getValue().equals(value));
    }

    public static String getDesc(Boolean value) {
        return IEnum.getDesc(UserSupers.class,
                enums -> enums.getValue().equals(value));
    }

    public static List<EnumsVo> getList(){
        return IEnum.findList(UserSupers.class).stream()
                .map(element -> new EnumsVo(element.getValue(), element.getDesc()))
                .collect(Collectors.toList());
    }
}
